﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WanPiJie;
using WanPiJie.Products;
using Collection.Entities;
using Collection.Core.Goods;

namespace Collection.Core.Processing
{
    public class Refining
    {
        #region 提取属性信息
        /// <summary>
        /// 提取属性信息
        /// </summary>
        /// <param name="attributesOversee">属性提取监视</param>
        public static void GeneralizeAttribute(Action<WanPiJie.Products.Attribute, string> attributesOversee)
        {
            var properties = ServiceFactory.CatalogService.GetProperties();
            WanPiJie.Products.Attribute attribute;
            foreach (var property in properties)
            {
                attribute = new WanPiJie.Products.Attribute
                {
                    ThirdId = property.Id,
                    Name = property.Name
                };
                WpjSf.CategoryService.Import(attribute, attributesOversee);
            }
        }
        #endregion

        #region 提取单品信息
        /// <summary>
        /// 提取奶粉单品
        /// </summary>
        /// <returns></returns>
        public static void GeneralizeSingleProduct(Action<SingleProduct, string> oversee)
        {
            IList<BaseGoods> generalizes = new List<BaseGoods> { 
				{new Milk(oversee)},{new Diapers(oversee)}
				,{new MilkBottle(oversee)},{new Nipple(oversee)}
			};
            foreach (var g in generalizes)
            {
                g.GeneralizeSingleProduct();
            }
        }
        #endregion
    }
}
